// cf-416e
// 题意：给定一个n(<=500)个点的无向带权图，现在对于所有点对(s, t)(t > s)，
//       要求至少在一条从s到t最短路上的边的边数。
//
// 题解：类似floyd。先求出所有点对的最短路。然后求出in_edge[s][t]表示
//       从s到t最短路且最后直接于t相连的不同点的个数，然后count[s][t]表示
//       s-t最短路上有经过的边的个数，只需要枚举s-t最短路上每个点i，
//       每个点的in_edge[s][i]的和。
//
//       in_edge和count都是类似floyd三重循环的时候算。
//
// run: $exec < input
#include <iostream>

int const maxn = 507;
int count[maxn][maxn];
int f[maxn][maxn];
int map[maxn][maxn];
int in_edge[maxn][maxn];
int n, m;

int main()
{
	std::ios::sync_with_stdio(false);
	std::cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) map[i][j] = f[i][j] = -1;
		map[i][i] = f[i][i] = 0;
	}
	for (int i = 0, x, y, z; i < m; i++) {
		std::cin >> x >> y >> z;
		map[x][y] = map[y][x] = z;
		f[x][y] = f[y][x] = z;
	}
	for (int k = 1; k <= n; k++)
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= n; j++) {
				if (f[i][k] == -1 || f[k][j] == -1) continue;
				int t = f[i][k] + f[k][j];
				if (f[i][j] == -1 || t <= f[i][j]) f[i][j] = t;
			}

	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++) {
			if (f[i][j] == -1) continue;
			for (int k = 1; k <= n; k++) {
				if (k == j || map[k][j] == -1 || f[i][k] == -1) continue;
				if (f[i][k] + map[k][j] == f[i][j])
					in_edge[i][j]++;
			}
		}

	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			for (int k = 1; k <= n; k++) {
				if (f[i][k] == -1 || f[k][j] == -1 || f[i][j] == -1) continue;
				if (f[i][k] + f[k][j] == f[i][j])
					count[i][j] += in_edge[i][k];
			}

	for (int i = 1; i <= n; i++)
		for (int j = i + 1; j <= n; j++) std::cout << count[i][j] << ' ';
	std::cout << '\n';
}

